package com.fastmobile.impl;

import java.text.ParseException;
import java.util.List;
import java.util.Date;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.transaction.Transaction;

import com.fastmobile.entity.Transactions;

public class UT {
	public static void main(String[] args) throws ParseException {
		
		EntityManagerFactory emf = Persistence.createEntityManagerFactory("com.fastmobile");
		EntityManager em = emf.createEntityManager();
		
		TransactionsImpl transactionImpl = new TransactionsImpl();
		transactionImpl.setEntityManager(em);
//		transactionImpl.unlockTransactionById("HCMSE1211-001", "12/02/2014");
		Transactions transaction =  transactionImpl.getTransactionById("SE1302/0001");
		System.out.println("ID: " + transaction.getTransactionId());
		System.out.println("Transaction Unlock: " + transaction.isTransactionUnlock());
		System.out.println("Date of Prealert: " + transaction.getDateofPrealert());
		Date today = new Date();
		transaction.setDateofPrealert(today);
		System.out.println("Today: " + today);
		transactionImpl.saveTransaction(transaction);
		System.out.println("=====================Test===================");
		
//		List<Transactions> list = transactionImpl.getAllTransaction();
//		List<Transactions> list = transactionImpl.getLockedTransactionByQuantity(10);
//		if (null != list && list.size() > 0) {
//			for (Transactions trans : list) {
//				System.out.println("ID: " + trans.getTransactionId());
//				System.out.println("Transaction Unlock: " + trans.isTransactionUnlock());
//				System.out.println("Date of Prealert: " + trans.getDateofPrealert());
//				System.out.println("-----------------");
//			}
//		}
		
		
	}
}
